{% extends "Common/AdminBase.html" %}
{% load filters %} 
{% block Location %}

<li class="current" ><a href='/AdminMain/Article/Index/'>文章列表</a></li>
<li>/</li>
<li class="current">图片新闻修改</li>


{% endblock %}


{% block content %}

		<link rel="stylesheet" href="/site_media/admin/kindeditor/themes/default/default.css" />
		<script charset="utf-8" src="/site_media/admin/kindeditor/kindeditor-min.js"></script>
		<script charset="utf-8" src="/site_media/admin/kindeditor/lang/zh_CN.js"></script>
<script type='text/javascript' src='/site_media/admin/My97DatePicker/WdatePicker.js'></script>

<div class="contentcontainer">
	
	<form action="#" AjaxForm="/AdminMain/ArticleImg/DoEdit/" Ajaxverify="$.AjaxFormVerify"    AjaxSuccess="onRefresh">
		<input type="hidden" id="KeyId" name="KeyId" value="{{Model.info.ContentId}}">
    {% include 'AdminMain/Article/ContentBase.html' %}
               <div style="width:100%;float:left">
					<p style="float:left;">
							 <input type="submit"  value="保存" onclick="saveOut()" class="btn"> 
							 <input type="submit"  value="保存到草稿" onclick="savecg()" class="btn">
                    </p>
				</div>
				<input type="hidden" name="State" id="State" value="1">
	 </form>
		 <br/>
	  <br/> <br/>
	  <div class="status info">
        	
        	<p><span>提示:</span>拖动列表交换图片的排列顺序.点击图片查看原图.</p>
        </div>
	<form id="listform" action="#" AjaxForm="/AdminMain/ArticleImg/List/"    AjaxSuccess="#imglist">
		<input type="hidden" id="KeyId" name="KeyId" value="{{Model.info.ContentId}}">
		<div id="imglist" ></div>
	 </form>
	<br/>  <br/>
	  <br/>
<form action="#" id="addform" AjaxForm="/AdminMain/ArticleImg/DoAddNewImg/" Ajaxverify="$.AjaxFormVerify"    AjaxSuccess="onAdd">
	<input type="hidden" name="ContentId" id="ContentId" value="{{Model.info.ContentId}}">

	      <div class="headings alt">
                <h2>添加图片</h2>
            </div>
            <div class="contentbox">
            	
            	  <div style="width:100%;float:left">
					<p style="float:left;width:350px">
                        <label for="textfield"><strong>标题</strong></label>
                        <input maxlength="20" name="Ttile" type="text"  alt="标题"  maxlength="100" class="inputbox"> 
						 	<br>  
						<br>
                    </p>
					</div>
                   <div style="width:100%;float:left">
					<p style="float:left;">
                        <label for="textfield"><strong>说明</strong></label>
						
						<textarea class="inputbox" alt="说明" name="Explain" v_maxlength="100"  rows="5" cols="150" style="margin-left: 0px; margin-right: 0px; width: 651px; " ></textarea>
						<span  vf_span="Explain"  class="smltxt red"></span>
						<br>
                    </p>
					
					<div style="width:100%;float:left">
					<p style="float:left;">
                        <label for="textfield"><strong>图片</strong></label>
						
						<input class="ke-input-text" type="hidden" id="newFileId" name="FileId"  /> <input type="button" id="uploadImg" value="上传" />
						<br>
						
						<img id="newImg" > </img>
						<br>
                    </p>
				    </div>
				</div>
	 
	  </div>
	  <script>
	  	function OnNewFile()
		{
			if($("#newFileId").val().length==0)
			{
				$.alert("请先上传图片");
				return false;
			}
		}
		
	  </script>
	    <div style="width:100%;float:left">
					<p style="float:left;">
							 <input type="submit"  value="添加"  onclick="return OnNewFile()" class="btn"> 
                    </p>
				</div>
</form>
	

</div>
		

<script>
var updatelist=function()
{
	$("#listform").submit();
};
$(updatelist)

function saveOut()
{
	$("#State").val("1");
}

function savecg()
{
	$("#State").val("3");
}

function OnChange()
{
	
}
	

	KindEditor.ready(function(K) {
				var uploadbutton = K.uploadbutton({
					button : K('#uploadImg')[0],
					fieldName : 'imgFile',
					url : '/AdminMain/SysFile/UpFile/?ModelId={{Model.info.ContentId}}',
					afterUpload : function(data) {
						if (data.error === 0) {
							var url = K.formatUrl(data.url, 'absolute');
							K('#newFileId').val(data.id);
							$('#newImg').attr("src",url);
							$('#newImg').attr("width",300);
							$('#newImg').attr("height",200);
						} else {
							alert(data.message);
						}
					},
					afterError : function(str) {
						alert('自定义错误信息: ' + str);
					}
				});
				uploadbutton.fileBox.change(function(e) {
					uploadbutton.submit();
				});

			});

function onAdd(obj)
{
	$.tips(obj.ErrorTxt);
	document.getElementById("addform").reset();
	$("#newImg").attr("src","#");
	$('#newImg').attr("width",0);
	$('#newImg').attr("height",0);
	updatelist();
}

function onRefresh(obj)
{
	$.tips(obj.ErrorTxt);
}
</script>
		
{% endblock %}

